#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;
class Solution
{
public:
    stack<char> stk;
    bool isValid(string s)
    {
        for (char &ch : s)
        {
            if (stk.empty() == true)
            {
                if (ch == ')' || ch == '}' || ch == ']')
                    return false;
                stk.push(ch);
            }
            else
            {
                char tpch = stk.top();
                switch (tpch)
                {
                case '(':
                    if (ch == ')')
                        stk.pop();
                    else
                        stk.push(ch);
                    break;
                case '{':
                    if (ch == '}')
                        stk.pop();
                    else
                        stk.push(ch);
                    break;
                case '[':
                    if (ch == ']')
                        stk.pop();
                    else
                        stk.push(ch);
                    break;
                default:
                    stk.push(ch);
                    break;
                }
            }
        }
        if (stk.empty() == true)
            return true;
        else
            return false;
    }
};
int main()
{
    string s = "([{)";
    Solution slover;
    if (slover.isValid(s) == false)
        printf("false\n");
    else
        printf("true\n");
    return 0;
}